3434#include < cstdint>
3535#include < string>
3636
37+ #include < bitset>
38+ #include < string>
39+
3740using namespace o2 ;
3841using namespace o2 ::framework;
3942using namespace o2 ::aod;
@@ -58,24 +61,13 @@ struct ft0CorrectedTable {
5861 HistogramRegistry histos{" Histos" , {}, OutputObjHandlingPolicy::AnalysisObject};
5962 void init (o2::framework::InitContext&)
6063 {
61- if (doprocessStandard && doprocessWithBypassFT0timeInMC) {
62- LOG (fatal) << " Both processStandard and processWithBypassFT0timeInMC are enabled. Pick one of the two" ;
63- }
64- if (!doprocessStandard && !doprocessWithBypassFT0timeInMC) {
65- LOG (fatal) << " No process is enabled. Pick one" ;
66- }
6764 ccdb->setURL (cfgUrl);
6865 ccdb->setTimestamp (cfgTimestamp);
6966 ccdb->setCaching (true );
7067 ccdb->setLocalObjectValidityChecking ();
7168 // Not later than now objects
7269 ccdb->setCreatedNotAfter (std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now ().time_since_epoch ()).count ());
7370
74- if (doprocessWithBypassFT0timeInMC) {
75- // From ps to ns
76- resoFT0A.value = resoFT0A.value / 1000 .f ;
77- resoFT0C.value = resoFT0C.value / 1000 .f ;
78- }
7971 if (!addHistograms) {
8072 return ;
8173 }
@@ -84,16 +76,11 @@ struct ft0CorrectedTable {
8476 histos.add (" t0AC" , " t0AC" , kTH1D , {{1000 , -1000 , 1000 , " t0AC (ns)" }});
8577 histos.add (" deltat0AC" , " deltat0AC" , kTH1D , {{1000 , -1 , 1 , " #Deltat0AC (ns)" }});
8678 histos.add (" deltat0ACps" , " deltat0ACps" , kTH1D , {{1000 , -1000 , 1000 , " #Deltat0AC (ps)" }});
87- if (doprocessWithBypassFT0timeInMC) {
88- histos.add (" MC/deltat0A" , " t0A" , kTH1D , {{1000 , -50 , 50 , " t0A (ps)" }});
89- histos.add (" MC/deltat0C" , " t0C" , kTH1D , {{1000 , -50 , 50 , " t0C (ps)" }});
90- histos.add (" MC/deltat0AC" , " t0AC" , kTH1D , {{1000 , -50 , 50 , " t0AC (ps)" }});
91- }
9279 }
9380
94- void processStandard (soa::Join<aod::Collisions, aod::EvSels> const & collisions,
95- BCsWithMatchings const &,
96- aod::FT0s const &)
81+ void process (soa::Join<aod::Collisions, aod::EvSels> const & collisions,
82+ BCsWithMatchings const &,
83+ aod::FT0s const &)
9784 {
9885 table.reserve (collisions.size ());
9986 float t0A = 1e10f;
@@ -131,94 +118,6 @@ struct ft0CorrectedTable {
131118 table (t0A, t0C);
132119 }
133120 }
134- PROCESS_SWITCH (ft0CorrectedTable, processStandard, " Process standard table (default)" , true );
135-
136- void processWithBypassFT0timeInMC (soa::Join<aod::Collisions, aod::EvSels, aod::McCollisionLabels> const & collisions,
137- soa::Join<BCsWithMatchings, aod::Timestamps> const & bcs,
138- aod::FT0s const &,
139- aod::McCollisions const &)
140- {
141- if (cfgCollisionSystem.value == -1 ) {
142- o2::parameters::GRPLHCIFData* grpo = ccdb->template getForTimeStamp <o2::parameters::GRPLHCIFData>(cfgPathGrpLhcIf,
143- bcs.iteratorAt (0 ).timestamp ());
144- cfgCollisionSystem.value = CollisionSystemType::getCollisionTypeFromGrp (grpo);
145- switch (cfgCollisionSystem.value ) {
146- case CollisionSystemType::kCollSyspp :
147- resoFT0A.value = 24 .f ;
148- resoFT0C.value = 24 .f ;
149- break ;
150- case CollisionSystemType::kCollSysPbPb :
151- resoFT0A.value = 5 .65f ;
152- resoFT0C.value = 5 .65f ;
153- break ;
154- default :
155- break ;
156- }
157- // Resolution is given in ps
158- resoFT0A.value = resoFT0A.value / 1000 .f ;
159- resoFT0C.value = resoFT0C.value / 1000 .f ;
160- }
161- table.reserve (collisions.size ());
162- float t0A = 1e10f;
163- float t0C = 1e10f;
164- float eventtimeMC = 1e10f;
165- float posZMC = 0 ;
166- bool hasMCcoll = false ;
167-
168- for (const auto & collision : collisions) {
169- hasMCcoll = false ;
170- eventtimeMC = 1e10f;
171- t0A = 1e10f;
172- t0C = 1e10f;
173- posZMC = 0 ;
174- const float vertexPV = collision.posZ ();
175- const float vertex_corr = vertexPV * invLightSpeedCm2NS;
176- constexpr float dummyTime = 30 .; // Due to HW limitations time can be only within range (-25,25) ns, dummy time is around 32 ns
177- if (collision.has_mcCollision ()) {
178- hasMCcoll = true ;
179- const auto & collisionMC = collision.mcCollision ();
180- eventtimeMC = collisionMC.t ();
181- posZMC = collisionMC.posZ ();
182- }
183- if (collision.has_foundFT0 ()) {
184- const auto & ft0 = collision.foundFT0 ();
185- const std::bitset<8 >& triggers = ft0.triggerMask ();
186- const bool ora = triggers[o2::ft0::Triggers::bitA];
187- const bool orc = triggers[o2::ft0::Triggers::bitC];
188-
189- if (ora && ft0.timeA () < dummyTime) {
190- t0A = ft0.timeA ();
191- if (hasMCcoll) {
192- const float diff = eventtimeMC - posZMC * invLightSpeedCm2NS + gRandom ->Gaus (0 .f , resoFT0A);
193- t0A = diff;
194- }
195- t0A += vertex_corr;
196- }
197- if (orc && ft0.timeC () < dummyTime) {
198- t0C = ft0.timeC ();
199- if (hasMCcoll) {
200- const float diff = eventtimeMC + posZMC * invLightSpeedCm2NS + gRandom ->Gaus (0 .f , resoFT0C);
201- t0C = diff;
202- }
203- t0C -= vertex_corr;
204- }
205- }
206- LOGF (debug, " T0 collision time T0A = %f, T0C = %f" , t0A, t0C);
207- if (addHistograms) {
208- histos.fill (HIST (" t0A" ), t0A);
209- histos.fill (HIST (" t0C" ), t0C);
210- histos.fill (HIST (" t0AC" ), (t0A + t0C) * 0 .5f );
211- histos.fill (HIST (" deltat0AC" ), t0A - t0C);
212- if (hasMCcoll) {
213- histos.fill (HIST (" MC/deltat0A" ), (t0A - eventtimeMC) * 1000 .f );
214- histos.fill (HIST (" MC/deltat0C" ), (t0C - eventtimeMC) * 1000 .f );
215- histos.fill (HIST (" MC/deltat0AC" ), ((t0A + t0C) * 0 .5f - eventtimeMC) * 1000 .f );
216- }
217- }
218- table (t0A, t0C);
219- }
220- }
221- PROCESS_SWITCH (ft0CorrectedTable, processWithBypassFT0timeInMC, " Process MC with bypass of the AO2D information. Use with care!" , false );
222121};
223122
224123WorkflowSpec defineDataProcessing (ConfigContext const & cfgc) { return WorkflowSpec{adaptAnalysisTask<ft0CorrectedTable>(cfgc)}; }
0 commit comments